<?php

namespace Catalog;

use Doctrine\ORM\Mapping as ORM;

/**
 * Catalog\Roles
 *
 * @ORM\Table(name="roles")
 * @ORM\Entity
 */
class Roles
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string $name
     *
     * @ORM\Column(name="name", type="string", length=16, nullable=false)
     */
    private $name;

    /**
     * @var string $description
     *
     * @ORM\Column(name="description", type="string", length=128, nullable=false)
     */
    private $description;

    /**
     * @var boolean $deletable
     *
     * @ORM\Column(name="deletable", type="boolean", nullable=false)
     */
    private $deletable;

    /**
     * @var \Doctrine\Common\Collections\ArrayCollection
     *
     * @ORM\ManyToMany(targetEntity="Catalog\Privileges", inversedBy="role")
     * @ORM\JoinTable(name="role_privilege",
     *   joinColumns={
     *     @ORM\JoinColumn(name="role_id", referencedColumnName="id")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="privilege_id", referencedColumnName="id")
     *   }
     * )
     */
    private $privilege;

    /**
     * @var Catalog\Roles
     *
     * @ORM\ManyToOne(targetEntity="Catalog\Roles")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
     * })
     */
    private $parent;

    public function __construct()
    {
        $this->privilege = new \Doctrine\Common\Collections\ArrayCollection();
    }
    

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Roles
     */
    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set description
     *
     * @param string $description
     * @return Roles
     */
    public function setDescription($description)
    {
        $this->description = $description;
        return $this;
    }

    /**
     * Get description
     *
     * @return string 
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set deletable
     *
     * @param boolean $deletable
     * @return Roles
     */
    public function setDeletable($deletable)
    {
        $this->deletable = $deletable;
        return $this;
    }

    /**
     * Get deletable
     *
     * @return boolean 
     */
    public function getDeletable()
    {
        return $this->deletable;
    }

    /**
     * Add privilege
     *
     * @param Catalog\Privileges $privilege
     */
    public function addPrivileges(\Catalog\Privileges $privilege)
    {
        $this->privilege[] = $privilege;
    }

    /**
     * Get privilege
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getPrivilege()
    {
        return $this->privilege;
    }

    /**
     * Set parent
     *
     * @param Catalog\Roles $parent
     * @return Roles
     */
    public function setParent(\Catalog\Roles $parent = null)
    {
        $this->parent = $parent;
        return $this;
    }

    /**
     * Get parent
     *
     * @return Catalog\Roles 
     */
    public function getParent()
    {
        return $this->parent;
    }
}